/*
Copyright (C) 2003 Michael Würtinger

This file is part of Dynamicengine.

Dynamicengine is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation, either version 3
of the License, or (at your option) any later version.

Dynamicengine is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Dynamicengine. If not, see http://www.gnu.org/licenses/.
*/


#include "include.h"
#include "display.h"


void init()
{
//	ShowCursor(false);//Hide cursor
	
	glClearColor(0.0, 0.0, 0.0, 0.0);//Set clearcolor 
	glShadeModel(GL_SMOOTH);
	//glEnable(GL_DEPTH_TEST);

	glPointSize(5.0);
	glLineWidth(1.5);
	glEnable(GL_POINT_SMOOTH);
	glEnable(GL_LINE_SMOOTH);
	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}

void display()
{
	glClear(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT);//Clear DepthBuffer


	Site.Draw();


	glutSwapBuffers();
}

void reshape(int w, int h)
{
	glViewport(0, 0, (GLsizei) w, (GLsizei) h);
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	gluPerspective(60.0, (GLfloat) w / (GLfloat) h, 0.1, 100.0);
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	glTranslatef(0.0, 0.0, -10);

	glRotatef(0.0, 0.0, 1.0, 0.0);
}

void calculateFPS()
{
	static int last_time;
	static int frames;

	frames++;	
	
	if(last_time != time(NULL))
	{
		//Print Frames per Second!
		printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b               \b\b\b\b\b\b\b\b\b\b\b\b\b\b\bFPS: %u", frames);
		frames = 0;
	}

	last_time = time(NULL);
}
